﻿<%@ Page Title="" Language="C#" MasterPageFile="MasterPage.master" AutoEventWireup="true"
    CodeFile="NewsManagement.aspx.cs" Inherits="Page_NewsManagement" %>

<%@ Import Namespace="EasyCode.Utility" %>
<%@ Register Src="~/Page/Usercontrol/ContentHeader.ascx" TagName="ContentHeader"
    TagPrefix="uc1" %>
<%@ Register Src="~/Page/Usercontrol/Message.ascx" TagName="Message" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript">
        $(document).ready(function () {
            $("#<%= TextBox_PublishDate.ClientID %>").datepicker();
            $("#<%= TextBox_Home.ClientID %>").datepicker();
            $("#<%= TextBox_Sub.ClientID %>").datepicker();
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <uc1:ContentHeader ID="ContentHeader1" GoToLabel="Add new news" PageTitle="Manage news"
        GoToLink="AddNews.aspx" runat="server" />
    <div class="body_content">
        <uc1:Message runat="server" ID="MessageAlert" />
        <asp:UpdateProgress ID="UpdateProgress_Main" AssociatedUpdatePanelID="UpdatePanelContent"
            runat="server" DynamicLayout="true" DisplayAfter="0">
            <ProgressTemplate>
                <div class="overlay">
                    <div class="loader">
                        <img id="Img1" runat="server" alt="Loading..." src="../App_Themes/img_data/loading.gif"
                            width="25" />
                    </div>
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
        <asp:UpdatePanel ID="UpdatePanelContent" runat="server" OnLoad="UpdatePanelContent_Load">
            <ContentTemplate>
                <div id="searchpanel" class="df_tbl_func_row">
                    <div class="formrow">
                        <label class="lb_small fl">
                            <%= Resources.News.Keyword%></label>
                        <div class="form_filed fl">
                            <asp:TextBox ID="TextBox_Title" CssClass="textbox_large" runat="server"></asp:TextBox></div>
                        <div class="form_filed fl">
                            <asp:DropDownList ID="DropDownList_PCategory" runat="server" CssClass="select">
                            </asp:DropDownList>
                        </div>
                        <div class="form_filed fl">
                            <asp:DropDownList ID="DropDownList_Status" runat="server" CssClass="select">
                                <asp:ListItem Selected="True" Text="--All Status --" Value=""></asp:ListItem>
                                <asp:ListItem Text="Activated" Value="1"></asp:ListItem>
                                <asp:ListItem Text="Inactive" Value="0"></asp:ListItem>
                            </asp:DropDownList>
                        </div>
                        <div class="form_filed fl">
                            <label class="lb fl">
                                <%= Resources.News.HomePage%></label>
                            <asp:CheckBox ID="CheckBox_IsShowHomePage" CssClass="custom_checkbox" runat="server" />
                        </div>
                        <div class="form_filed fl">
                            <asp:DropDownList ID="DropDownList_HomePagePosition" runat="server" CssClass="select">
                            </asp:DropDownList>
                        </div>
                        <div class="clr">
                        </div>
                    </div>
                    <div class="formrow">
                        <label class="lb_small fl">
                        </label>
                        <div class="form_filed fl">
                            <asp:DropDownList ID="DropDownList_SubPage" runat="server" CssClass="select">
                            </asp:DropDownList>
                        </div>
                        <div class="form_filed fl">
                            <label class="lb fl">
                                <%= Resources.News.PublishDate%></label>
                            <asp:TextBox ID="TextBox_PublishDate" CssClass="textbox_smaller" runat="server"></asp:TextBox>
                        </div>
                        <div class="form_filed fl">
                            <label class="lb fl">
                                <%= Resources.News.HomePageModifiedDate%></label>
                            <asp:TextBox ID="TextBox_Home" CssClass="textbox_smaller" runat="server"></asp:TextBox>
                        </div>
                        <div class="form_filed fl">
                            <label class="lb fl">
                                <%= Resources.News.SubPageModifiedDate%></label>
                            <asp:TextBox ID="TextBox_Sub" CssClass="textbox_smaller" runat="server"></asp:TextBox>
                        </div>
                        <div class="clr">
                        </div>
                    </div>
                    <div class="formrow">
                        <div class="form_btn">
                            <label class="lb_small fl">
                            </label>
                            <div class="df_ibtn fl">
                                <asp:Button ID="Button_Search" runat="server" Text="Search" OnClick="Button_Search_Click" />
                            </div>
                            <div class="df_ibtn fl">
                                <asp:Button ID="Button_Cancel" runat="server" Text="Refresh" OnClick="Button_Cancel_Click" />
                            </div>
                        </div>
                    </div>
                </div>
                <asp:Literal ID="Literal_PagingListTop" runat="server"></asp:Literal>
                <table width="100%" cellspacing="0" cellpadding="0" class="df_table">
                    <tr>
                        <th style="width: 20px">
                        </th>
                        <th>
                            News Title
                        </th>
                        <th style="width: 5%">
                            Category
                        </th>
                        <th style="width: 5%">
                            Movie Style
                        </th>
                        <th style="width: 7%">
                            Home Page Position
                        </th>
                        <th style="width: 7%">
                            Sub Page Position
                        </th>
                        <th style="width: 3%" class="center">
                            Avatar
                        </th>
                        <th style="width: 3%" class="center">
                            Slider
                        </th>
                        <th style="width: 4%" class="center">
                            Views
                        </th>
                        <th style="width: 6%" class="center">
                            Created date
                        </th>
                        <th style="width: 6%" class="center">
                            Publish date
                        </th>
                        <th style="width: 3%" class="center">
                            Home
                        </th>
                        <th style="width: 5%" class="center">
                            Permission Preview
                        </th>
                        <th style="width: 4%" class="center">
                        </th>
                    </tr>
                    <asp:Repeater runat="server" ID="Repeater_Content" OnItemCommand="Repeater_Content_ItemCommand">
                        <ItemTemplate>
                            <tr class="<%# Container.ItemIndex % 2 == 0 ? "odd" : "even" %>">
                                <td>
                                    <div title="View comment list" class="cell_inner icon_expand" id='divclick<%# Container.ItemIndex %>' onclick=" return GetCommentList('<%# Container.ItemIndex %>', '<%# Eval("NewsID") %>','<%# GetNumOfRow() %>');">
                                        +</div>
                                </td>
                                <td>
                                    <%# Protector.String(Eval("NewsTitle"))%>
                                </td>
                                <td>
                                    <%# Protector.String(Eval("Category.CategoryName"))%>
                                </td>
                                <td>
                                    <%# Protector.String(Eval("NewsMovieType.MovieTypeName"))%>
                                </td>
                                <td>
                                    <%# Protector.String(Eval("NewsPosition1.PositionName"))%>
                                </td>
                                <td>
                                    <%# Protector.String(Eval("NewsPosition.PositionName"))%>
                                </td>
                                <td align="center">
                                    <%# string.IsNullOrEmpty(Protector.String(Eval("AvatarImage"))) ? "" : "<img style=\"cursor: pointer;\" src=\"../App_Themes/img_data/i_photo.gif\" onmouseout=\"UnTip();\" onmouseover=\"Tip('<img src=" + ResolveUrl( Protector.String(Eval("AvatarImage"))) + " width=100 />',BGCOLOR, '#ffffff', BORDERCOLOR, '#cccccc', BORDERWIDTH, 1, WIDTH, 'auto', FONTCOLOR,'#58792E')\" alt=\"\" />"%>
                                </td>
                                <td align="center">
                                    <%# string.IsNullOrEmpty(Protector.String(Eval("SliderPath"))) ? "" : "<img style=\"cursor: pointer;\" src=\"../App_Themes/img_data/i_photo.gif\" onmouseout=\"UnTip();\" onmouseover=\"Tip('<img src=" + ResolveUrl(Protector.String(Eval("SliderPath"))) + " width=100 />',BGCOLOR, '#ffffff', BORDERCOLOR, '#cccccc', BORDERWIDTH, 1, WIDTH, 'auto', FONTCOLOR,'#58792E')\" alt=\"\" />"%>
                                </td>
                                <td class="center">
                                    <%# Protector.Int(Eval("NewsTotalView"))%>
                                </td>
                                <td align="right">
                                    <%# Protector.DateTime(Eval("CreatedDate")).ToShortDateString()%>
                                </td>
                                <td align="right">
                                    <%# Protector.DateTime(Eval("PublishDate")).ToShortDateString()%>
                                </td>
                                <td align="center">
                                    <asp:LinkButton runat="server" ID="LinkButton_ChangeHomePageStatus" ToolTip='Change home page status'
                                        OnClientClick='return ConfirmAction("Are you sure you want to change the selected news home page status?");'
                                        CommandName="changehomepage" CommandArgument='<%# Eval("NewsID") %>'>
                                    <%# Protector.Bool(Eval("ShowHomePage"), false) ? "<img src='../App_Themes/themes/default/images/func_icons/checked.png' alt='' />" : "<img src='../App_Themes/themes/default/images/func_icons/uncheck.png' alt='' />"%>
                                    </asp:LinkButton>
                                </td>
                                <td align="center">
                                    <asp:LinkButton runat="server" ID="LinkButton_ChangeStatus" ToolTip='Change status'
                                        OnClientClick='return ConfirmAction("Are you sure you want to change the selected news status?");'
                                        CommandName="LockUnLockCommand" CommandArgument='<%# Eval("NewsID") %>'>
                                    <%# Protector.Bool(Eval("Status"), false) ? "<img src='../App_Themes/themes/default/images/func_icons/checked.png' alt='' />" : "<img src='../App_Themes/themes/default/images/func_icons/uncheck.png' alt='' />"%>
                                    </asp:LinkButton>
                                </td>
                                <td class="center">
                                    <asp:HyperLink runat="server" ID="LinkButton_Edit" ToolTip='Edit' NavigateUrl='<%# "AddNews.aspx?id=" + Eval("NewsID")%>'
                                        CssClass="edit_icon"></asp:HyperLink>
                                    <asp:LinkButton runat="server" ID="LinkButton_Delete" ToolTip="Delete" CommandName="DeleteCommand"
                                        CssClass="del_icon" CausesValidation="false" CommandArgument='<%# Eval("NewsID") %>'
                                        OnClientClick='return ConfirmAction("Are you sure you want to permanently delete the selected news?");'></asp:LinkButton>
                                </td>
                            </tr>
                            <tr id='expand<%# Container.ItemIndex  %>' style="display: none">
                                <td colspan="14" class="tbl_subcell">
                                    <div class="tbl_subcell_inner">
                                        <asp:Repeater ID="RepeaterCommentList" runat="server">
                                            <HeaderTemplate>
                                                <table width="100%" cellspacing="0" cellpadding="0">
                                                    <tbody>
                                                        <tr>
                                                            <th width="20%">
                                                                Comment title
                                                            </th>
                                                            <th>
                                                                Detail
                                                            </th>
                                                            <th width="5%" class="center">
                                                                By
                                                            </th>
                                                            <th width="6%" class="center">
                                                                Date
                                                            </th>
                                                        </tr>
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <tr class="even">
                                                    <td>
                                                        <%# EasyCode.Utility.Protector.String(Eval("CommentTitle"))%>
                                                    </td>
                                                    <td>
                                                        <%# EasyCode.Utility.Protector.String(Eval("CommentDetail"))%>
                                                    </td>
                                                    <td align="right">
                                                        <%# Eval("CreatedBy")%>
                                                    </td>
                                                    <td align="right">
                                                        <%# EasyCode.Utility.Protector.DateTime(Eval("CreatedDate")).ToShortDateString()%>
                                                    </td>
                                                </tr>
                                            </ItemTemplate>
                                            <FooterTemplate>
                                                </tbody> </table>
                                            </FooterTemplate>
                                        </asp:Repeater>
                                    </div>
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                    <tr runat="server" id="tr_not_found" visible="false">
                        <td colspan="6">
                            Data not found.
                        </td>
                    </tr>
                </table>
                <asp:Literal ID="Literal_PagingListBot" runat="server"></asp:Literal>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <script type="text/javascript">
        var clickedID = new Array();
        function loadpage(page) {
            __doPostBack('<%= UpdatePanelContent.ClientID %>', page + '|page');
        }
        function GetCommentList(id, newsID, numOfRow) {
            var isClicked = false;
            for (i = 0; i < numOfRow; i++) {
                if (i != id) {
                    $('#expand' + i).hide();
                    $('#divclick' + i).removeClass('icon_collapse');
                    $('#divclick' + i).addClass('icon_expand');
                }
                else {
                    var trdisplay = $('#expand' + id).css('display');
                    if (trdisplay == 'none') {
                        $('#expand' + id).show();
                        $('#divclick' + id).removeClass('icon_expand');
                        $('#divclick' + id).addClass('icon_collapse');
                    }
                    else {
                        $('#expand' + id).hide();
                        $('#divclick' + id).removeClass('icon_collapse');
                        $('#divclick' + id).addClass('icon_expand');
                    }
                }
            }
            if (clickedID.length == 0) {
                clickedID.push(id);
                __doPostBack('<%= UpdatePanelContent.ClientID %>', id + '|divid|' + newsID + '|newid');
            }
            else {
                for (j = 0; j < clickedID.length; j++) {
                    if (id == clickedID[j]) {
                        isClicked = true;
                        if (trdisplay == 'none') {
                            //$('#expand' + id).show();
                            $('#divclick' + id).removeClass('icon_expand');
                            $('#divclick' + id).addClass('icon_collapse');
                        }
                        else {
                            $('#divclick' + id).removeClass('icon_collapse');
                            $('#divclick' + id).addClass('icon_expand');
                        }
                    }
                    else {
                        $('#divclick' + j).removeClass('icon_collapse');
                        $('#divclick' + j).addClass('icon_expand');
                    }
                }
            }
            if (!isClicked) {
                clickedID.push(id);
                __doPostBack('<%= UpdatePanelContent.ClientID %>', id + '|divid|' + newsID + '|newid');
            }
        }
        function ConfirmAction(message) {
            return confirm(message);
        }
        function ExpandCollapse(id) {
            $('#expand' + id).show();
            $('#divclick' + id).removeClass('icon_expand');
            $('#divclick' + id).addClass('icon_collapse');
        }
    </script>
</asp:Content>
